package com.magicsoft.share.constant;

import com.magicsoft.share.bean.article.MyArticleDetail;
import com.magicsoft.share.bean.exchange.AddressDefault;
import com.magicsoft.share.bean.exchange.Freight;
import com.magicsoft.share.bean.exchange.GoodsDetail;
import com.magicsoft.share.bean.exchange.GoodsList;
import com.magicsoft.share.bean.exchange.GoodsType;
import com.magicsoft.share.bean.exchange.ShopCartGoods;
import com.magicsoft.share.bean.exchange.SubmitOrder;
import com.magicsoft.share.bean.main.SMSCode;
import com.magicsoft.share.bean.main.User;
import com.magicsoft.share.bean.my.Address;
import com.magicsoft.share.bean.my.AlipayParam;
import com.magicsoft.share.bean.my.ArticleList;
import com.magicsoft.share.bean.my.GoldDetail;
import com.magicsoft.share.bean.my.InstructionModel;
import com.magicsoft.share.bean.my.LoginShareBean;
import com.magicsoft.share.bean.my.MessageList;
import com.magicsoft.share.bean.my.MessageRead;
import com.magicsoft.share.bean.my.OrderList;
import com.magicsoft.share.bean.my.RankList;
import com.magicsoft.share.bean.my.UserInfo;
import com.magicsoft.share.bean.my.UserList;
import com.magicsoft.share.bean.my.WxParameter;
import com.magicsoft.share.bean.share.Article;
import com.magicsoft.share.bean.share.ArticleType;
import com.magicsoft.share.bean.share.Banner;
import com.magicsoft.share.bean.share.CommentList;
import com.magicsoft.share.bean.share.OtherUserDetail;
import com.magicsoft.share.bean.share.ReportType;
import com.magicsoft.share.bean.share.Special;
import com.magicsoft.share.rx_retrofit_network.location.model.BaseResponse;

import java.util.List;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Header;
import retrofit2.http.POST;

/**
 * @author lyf
 * @date 2017/11/14/014
 */

public interface APIService {


    @FormUrlEncoded
    @POST(Url.CHECK_LOGIN)
    Observable<BaseResponse> checkLogin(@Field("appUserId") long appUserId);

    /**
     * 获取验证码
     *
     * @param method 1000：验证手机号不存在；1001：验证手机号码存在
     * @param phone
     * @return
     */
    @FormUrlEncoded
    @POST(Url.SEND_CODE)
    Observable<BaseResponse<SMSCode>> sendCode(@Field("method") String method, @Field("phone") String phone);

    @FormUrlEncoded
    @POST(Url.CHECK_SMS_CODE)
    Observable<BaseResponse> checkSmsCode(@Field("phone") String phone, @Field("smsCode") String smsCode, @Field("method") String method);

    @FormUrlEncoded
    @POST(Url.USER_REGISTER)
    Observable<BaseResponse> userRegister(@Field("phone") String phone, @Field("password") String password, @Field("smsCode") String smsCode);

    @FormUrlEncoded
    @POST(Url.USER_LOGIN)
    Observable<BaseResponse<User>> userLogin(@Field("phone") String phone, @Field("password") String password);

    @FormUrlEncoded
    @POST(Url.USER_DETAIL)
    Observable<BaseResponse<UserInfo>> userDetail(@Header("Authorization") String token, @Field("appUserId") long appUserId);

    @FormUrlEncoded
    @POST(Url.CHECK_OLD_PASSWORD)
    Observable<BaseResponse> checkOldPassword(@Header("Authorization") String token, @Field("appUserId") long appUserId, @Field("oldPassword") String oldPassword);


    @FormUrlEncoded
    @POST(Url.EDIT_USER_DETAIL)
    Observable<BaseResponse> editUserDetail(@Header("Authorization") String token, @Field("id") long appUserId,
                                            @Field("oldPassword") String oldPassword, @Field("password") String password,
                                            @Field("nickname") String nickname, @Field("headimg") String headimg,
                                            @Field("personalizedSignature") String personalizedSignature, @Field("region") String region,
                                            @Field("birthday") String birthday);

    /**
     * @param token
     * @param appUserId
     * @param type      1：我的关注；2：我的粉丝
     * @param pageNum
     * @param pageSize
     * @return
     */
    @FormUrlEncoded
    @POST(Url.FOLLOW_FANS_LIST)
    Observable<BaseResponse<UserList>> followFansList(@Header("Authorization") String token, @Field("appUserId") long appUserId,
                                                      @Field("type") String type, @Field("pageNum") int pageNum,
                                                      @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST(Url.DELETE_FOLLOW)
    Observable<BaseResponse> deleteFollow(@Header("Authorization") String token,
                                          @Field("myId") long myId, @Field("otherId") long otherId);

    @FormUrlEncoded
    @POST(Url.ADD_FOLLOW)
    Observable<BaseResponse> addFollow(@Header("Authorization") String token, @Field("fromId") long fromId,
                                       @Field("targetId") long targetId);

    @FormUrlEncoded
    @POST(Url.MY_ARTICLE_LIST)
    Observable<BaseResponse<ArticleList>> myArticleList(@Header("Authorization") String token, @Field("appUserId") long appUserId,
                                                        @Field("pageNum") int pageNum, @Field("pageSize") int pageSize,
                                                        @Field("status") byte status);

    @FormUrlEncoded
    @POST(Url.MY_COLLECTION)
    Observable<BaseResponse<ArticleList>> myCollection(@Header("Authorization") String token, @Field("appUserId") long appUserId,
                                                       @Field("pageNum") int pageNum, @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST(Url.MY_AMOUNT_DETAIL)
    Observable<BaseResponse<GoldDetail>> myAmountDetail(@Header("Authorization") String token, @Field("appUserId") long appUserId,
                                                        @Field("pageNum") int pageNum, @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST(Url.WEEK_RANKING_FOR_USER)
    Observable<BaseResponse<String>> weekRankingForUser(@Header("Authorization") String token, @Field("appUserId") long appUserId);


    @FormUrlEncoded
    @POST(Url.WEEK_RANKING)
    Observable<BaseResponse<RankList>> weekRanking(@Header("Authorization") String token,
                                                   @Field("pageNum") int pageNum, @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST(Url.ALL_RANKING)
    Observable<BaseResponse<RankList>> allRanking(@Header("Authorization") String token,
                                                  @Field("pageNum") int pageNum, @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST(Url.MESSAGE_READ)
    Observable<BaseResponse<MessageRead>> messageRead(@Header("Authorization") String token, @Field("appUserId") long appUserId);

    @FormUrlEncoded
    @POST(Url.MESSAGE_LIST)
    Observable<BaseResponse<MessageList>> messageList(@Header("Authorization") String token, @Field("appUserId") long appUserId,
                                                      @Field("messageType") int messageType,
                                                      @Field("pageNum") int pageNum, @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST(Url.MY_ORDER_LIST)
    Observable<BaseResponse<OrderList>> myOrderList(@Header("Authorization") String token, @Field("appUserId") long appUserId,
                                                    @Field("status") int status,
                                                    @Field("pageNum") int pageNum, @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST(Url.CONFIRM_ORDER)
    Observable<BaseResponse> confirmOrder(@Header("Authorization") String token, @Field("orderId") long orderId);


    @FormUrlEncoded
    @POST(Url.ADDRESS_LIST)
    Observable<BaseResponse<List<Address>>> addressList(@Header("Authorization") String token, @Field("appUserId") long appUserId);


    @FormUrlEncoded
    @POST(Url.SAVE_ADDRESS)
    Observable<BaseResponse> saveAddress(@Header("Authorization") String token, @Field("appUserId") long appUserId,
                                         @Field("id") Long id, @Field("whetherDefault") int whetherDefault,
                                         @Field("appUserName") String appUserName, @Field("phone") String phone,
                                         @Field("region") String region, @Field("addressDetail") String addressDetail,
                                         @Field("postalCode") String postalCode);

    @FormUrlEncoded
    @POST(Url.DELETE_ADDRESS)
    Observable<BaseResponse> deleteAddress(@Header("Authorization") String token, @Field("addressId") long addressId);

    @FormUrlEncoded
    @POST(Url.OPINION_FEEDBACK)
    Observable<BaseResponse> opinionFeedback(@Header("Authorization") String token, @Field("appUserId") long appUserId, @Field("content") String content);

    @FormUrlEncoded
    @POST(Url.FIND_USER_FORHOME)
    Observable<BaseResponse<UserList>> findUserForHome(@Field("appUserId") Long appUserId, @Field("keyword") String keyword, @Field("pageNum") int pageNum, @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST(Url.SEE_USER_DETAIL)
    Observable<BaseResponse<OtherUserDetail>> seeUserDetail(@Field("myId") Long myId, @Field("otherId") Long otherId);


    @POST(Url.ARTICLE_TYPE_LIST)
    Observable<BaseResponse<List<ArticleType>>> articleTypeList();


    @FormUrlEncoded
    @POST(Url.ARTICLE_LIST)
    Observable<BaseResponse<ArticleList>> articleList(@Field("app_user_id") long app_user_id, @Field("articleSpecial") Integer articleSpecial, @Field("pageNum") int pageNum,
                                                      @Field("pageSize") int pageSize, @Field("articleType") Integer articleType,
                                                      @Field("keyword") String keyword, @Field("isHot") Integer isHot, @Field("otherId") Long otherId);


    @FormUrlEncoded
    @POST(Url.GET_ARTICLE_DETAIL)
    Observable<BaseResponse<Article>> getArticleDetail(@Field("appUserId") Long appUserId, @Field("articleId") long articleId);

    @FormUrlEncoded
    @POST(Url.ARTICLE_LOVE)
    Observable<BaseResponse<Article>> articleLove(@Header("Authorization") String token, @Field("appUserId") Long appUserId, @Field("articleId") long articleId);

    @FormUrlEncoded
    @POST(Url.DELETE_ARTICLE_LOVE)
    Observable<BaseResponse<Article>> deleteArticleLove(@Header("Authorization") String token, @Field("appUserId") Long appUserId, @Field("articleId") long articleId);


    @FormUrlEncoded
    @POST(Url.COMMENT_LIST)
    Observable<BaseResponse<CommentList>> commentList(@Field("articleId") long articleId, @Field("pageNum") int pageNum, @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST(Url.ADD_COMMENT)
    Observable<BaseResponse> addComment(@Header("Authorization") String token, @Field("appUserId") long appUserId, @Field("articleId") long articleId, @Field("content") String content);

    @FormUrlEncoded
    @POST(Url.ARTICLE_COLLECTION)
    Observable<BaseResponse> articleCollection(@Header("Authorization") String token, @Field("appUserId") long appUserId, @Field("articleId") long articleId);

    @FormUrlEncoded
    @POST(Url.DELETE_COLLECTION)
    Observable<BaseResponse> deleteCollection(@Header("Authorization") String token, @Field("appUserId") long appUserId, @Field("articleId") long articleId);


    @POST(Url.REPORT_TYPE_LIST)
    Observable<BaseResponse<List<ReportType>>> reportTypeList(@Header("Authorization") String token);

    @FormUrlEncoded
    @POST(Url.REPORT)
    Observable<BaseResponse> report(@Header("Authorization") String token, @Field("fromId") long fromId, @Field("targetId") long targetId
            , @Field("articleId") long articleId, @Field("reportType") String reportType);

    @FormUrlEncoded
    @POST(Url.BANNER_LIST)
    Observable<BaseResponse<List<Banner>>> bannerList(@Field("bannerType") int bannerType);


    @FormUrlEncoded
    @POST(Url.article_Special_List)
    Observable<BaseResponse<List<Special>>> articleSpecialList(@Field("articleTypeId") int articleTypeId);


    @POST(Url.GOODS_TYPE_LIST)
    Observable<BaseResponse<List<GoodsType>>> goodsTypeList();


    @FormUrlEncoded
    @POST(Url.GOODS_LIST)
    Observable<BaseResponse<GoodsList>> goodsList(@Field("pageNum") int pageNum, @Field("pageSize") int pageSize, @Field("goodsType") int goodsType, @Field("isRecommend") Integer isRecommend);

    @FormUrlEncoded
    @POST(Url.GOODS_DETAIL)
    Observable<BaseResponse<GoodsDetail>> goodsDetail(@Field("goodsId") long goodsId);


    @FormUrlEncoded
    @POST(Url.JOIN_SHOP_CART)
    Observable<BaseResponse> joinShopCart(@Header("Authorization") String token, @Field("appUserId") long appUserId, @Field("goodsId") long goodsId, @Field("goodsNum") int goodsNum);

    @FormUrlEncoded
    @POST(Url.SHOP_CART_GOODS)
    Observable<BaseResponse<ShopCartGoods>> shopCartGoods(@Header("Authorization") String token, @Field("appUserId") long appUserId, @Field("pageNum") int pageNum, @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST(Url.DELETE_GOODS)
    Observable<BaseResponse> deleteGoods(@Header("Authorization") String token, @Field("appUserId") long appUserId, @Field("goodsIds") String goodsIds);

    @FormUrlEncoded
    @POST(Url.GOODS_IS_VALID)
    Observable<BaseResponse> goodsIsValid(@Field("goodsList") String goodsList);

    @FormUrlEncoded
    @POST(Url.SUBMIT_ORDER)
    Observable<BaseResponse<SubmitOrder>> submitOrder(@Header("Authorization") String token, @Field("appUserId") long appUserId, @Field("orderAmount") int orderAmount, @Field("goodsList") String goodsList);

    @POST(Url.FREIGHT)
    Observable<BaseResponse<Freight>> freight();

    @FormUrlEncoded
    @POST(Url.ADDRESS_DEFAULT)
    Observable<BaseResponse<AddressDefault>> addressDefault(@Header("Authorization") String token, @Field("appUserId") long appUserId);

    @FormUrlEncoded
    @POST(Url.ADD_ORDER)
    Observable<BaseResponse> addOrder(
            @Header("Authorization") String token,
            @Field("appUserId") long appUserId,
            @Field("userName") String userName,
            @Field("phone") String phone,
            @Field("orderAmount") int orderAmount,
            @Field("address") String address,
            @Field("freight") int freight,
            @Field("goodsList") String goodsList,
            @Field("password") String password,
            @Field("isDirect") int isDirect,
            @Field("lockStockId") long lockStockId
    );

    @FormUrlEncoded
    @POST(Url.ARTICLE_PREVIEW)
    Observable<BaseResponse<String>> articlePreview(@Field("nickname") String nickname, @Field("title") String title, @Field("content") String content);

    @FormUrlEncoded
    @POST(Url.ARTICLE_EDIT)
    Observable<BaseResponse> articleEdit(@Header("Authorization") String token, @Field("appUserId") long appUserId,
                                         @Field("id") Long id,
                                         @Field("title") String title, @Field("cover") String cover, @Field("coverRiginal") String coverRiginal,
                                         @Field("content") String content, @Field("isAllowComment") Integer isAllowComment, @Field("isOpen") Integer isOpen, @Field("articleType") Integer articleType, @Field("special") Integer special, @Field("status") Integer status
    );

    @FormUrlEncoded
    @POST(Url.DELETE_ARTICLE)
    Observable<BaseResponse> deleteArticle(@Header("Authorization") String token, @Field("articleId") long articleId);

    @FormUrlEncoded
    @POST(Url.MY_ARTICLE_DETAIL)
    Observable<BaseResponse<MyArticleDetail>> myArticleDetail(@Header("Authorization") String token, @Field("articleId") long articleId);


    //获取支付宝支付参数
    @FormUrlEncoded
    @POST(Url.ALIPAY_PARAMM)
    Observable<BaseResponse<AlipayParam>> getAlipayParam(@Field("qixiangNo") String shareId,
                                                         @Field("appUserId") Long appUserId);

    //获取微信支付参数
    @FormUrlEncoded
    @POST(Url.WECHAT_PARARM)
    Observable<BaseResponse<WxParameter>> getWechatPayParam(@Field("qixiangNo") String shareId,
                                                            @Field("appUserId") Long appUserId);

    //奇享号验证
    @FormUrlEncoded
    @POST(Url.CHECK_QXCODE)
    Observable<BaseResponse<Boolean>> checkQXCode(
            @Field("qixiang_no") String qixiang_no
    );

    //奇享号分享
    @FormUrlEncoded
    @POST(Url.LOGIN_SHARE_TWO)
    Observable<BaseResponse<LoginShareBean>> loginShare(
            @Header("Authorization") String token,
            @Field("") String lalla
    );


    /**
     *  邀请说明
     * @return
     */
    @FormUrlEncoded
    @POST(Url.INSTRUCTION)
    Observable<BaseResponse<InstructionModel>>instruction(
    );
}
